<?php
    include_once('Configs/database.php');
    include_once('Models/HocPhan.php');
    include_once('Models/HocKiNamHoc.php');
    class HPMoVaoHKNH extends database{
        private $mahp;
        private $hocki;
        private $namhoc;
        public function setMaHP($mahp){
            $this->mahp = $mahp;
        }
        public function getMaHP(){
            return $this->mahp;
        }
        public function setHocKi($hocki){
            $this->hocki = $hocki;
        }
        public function getHocKi(){
            return $this->hocki;
        }
        public function setNamHoc($namhoc){
            $this->namhoc = $namhoc;
        }        
        public function getNamHoc(){
            return $this->namhoc;
        }
        public function dsHocPhanDayVaoHKNHCuaCBGD($maso){
            $this->setQuery("select distinct a.mahp,tenhp from HocPhan a, HPMoVaoHKNH b, LopHocPhan c where  b.namhoc='".$this->getNamHoc()."' and b.hocki=".$this->getHocKi()." and c.maso = '".$maso."' and a.mahp = b.mahp and a.mahp = c.mahp order by tenhp asc");
			
            return $this->fetchAll();
        }
        public function dsHocPhanMoVaoHKNH(){
            $this->setQuery("select * from HocPhan a, HPMoVaoHKNH b "
							. "where b.namhoc='".$this->getNamHoc()."' and b.hocki=".$this->getHocKi()." and a.mahp = b.mahp");
			
            return $this->fetchAll();
        }
        public function themHPMoVaoHKNH(){
            $this->setQuery("insert HPMoVaoHKNH(mahp,hocki,namhoc) values ('".$this->getMaHP()."',".$this->getHocKi().",'".$this->getNamHoc()."')");
            return $this->executeQuery();
        }
        
        public function xoaHPMoVaoHKNH(){
            $this->setQuery("delete from HPMoVaoHKNH where mahp='".$this->getMaHP()."' and hocki=".$this->getHocKi()." and namhoc= '".$this->getNamHoc()."'");
            return $this->executeQuery();
        }
    }
?>